#ifndef JSON_UTIL_H
#define JSON_UTIL_H
#include "private_implementations/JsonObjectNode.h"
#include "private_implementations/JsonArrayNode.h"

namespace simframework
{
	namespace json
	{
		class JSONUtil
		{
		public:
			JSONUtil(void);
			~JSONUtil(void);

			static SimWString		getKey(SimWStringIter& startIt, SimWStringIter& endIt);
			static void				skipValue(SimWStringIter& startIt, SimWStringIter& endIt);
			static void				skipString(SimWStringIter& startIt, SimWStringIter& endIt);
			static void				skipNumber(SimWStringIter& startIt, SimWStringIter& endIt);
			static void				skipBoolean(SimWStringIter& startIt, SimWStringIter& endIt);
			static void				skipNull(SimWStringIter& startIt, SimWStringIter& endIt);
			static void				skipObjectOrArray(SimWStringIter& startIt, SimWStringIter& endIt);
			static void				removeSpaces(SimWStringIter& startIt, SimWStringIter& endIt);
			static void				cleanUp(SimWStringIter& startIt, SimWStringIter& endIt);

			static JsonObjectNode*	getObjectValue(SimWStringIter& startIt, SimWStringIter& endIt, int* status);
			static JsonArrayNode*	getArrayValue(SimWStringIter& startIt, SimWStringIter& endIt, int* status);
			static JSONString*		getStringValue(SimWStringIter& startIt, SimWStringIter& endIt, int* status);
			static JSONFloat*		getFloatValue(SimWStringIter& startIt, SimWStringIter& endIt, int* status);
			static JSONInteger*		getIntValue(SimWStringIter& startIt, SimWStringIter& endIt, int* status);
			static JSONBoolean*		getBooleanValue(SimWStringIter& startIt, SimWStringIter& endIt, int* status);

			static bool				isDigit(wchar_t& c);
			static bool				checkForNull(SimWStringIter& startIt, SimWStringIter& endIt);
			static bool				checkPatternString(SimWString& pattern, SimWStringIter& startIt, SimWStringIter& endIt);
			static JsonObjectNode*	getObjectElementById(unsigned int elemId, unsigned int& start, 
				SimWStringIter& startIt, SimWStringIter& endIt, int* status);
			static JsonArrayNode*	getArrayElementById(unsigned int elemId, unsigned int& start, 
				SimWStringIter& startIt, SimWStringIter& endIt, int* status);
			static JSONString*		getStringElementById(unsigned int elemId, unsigned int& start, 
				SimWStringIter& startIt, SimWStringIter& endIt, int* status);
			static JSONFloat*		getFloatElementById(unsigned int elemId, unsigned int& start, 
				SimWStringIter& startIt, SimWStringIter& endIt, int* status);
			static JSONInteger*		getIntElementById(unsigned int elemId, unsigned int& start, 
				SimWStringIter& startIt, SimWStringIter& endIt, int* status);
			static JSONBoolean*		getBooleanElementById(unsigned int elemId, unsigned int& start, 
				SimWStringIter& startIt, SimWStringIter& endIt, int* status);
			static JsonAbstractNode*	getDefault(JSONType type);
		};

		static /*const*/ JsonObjectNode		DEFAULT_JSON_OBJECT(L"");
		static /*const*/ JsonArrayNode		DEFAULT_JSON_ARRAY(L"");
		static /*const*/ JSONString			DEFAULT_JSON_STRING;
		static /*const*/ JSONBoolean		DEFAULT_JSON_BOOLEAN;
		static /*const*/ JSONFloat			DEFAULT_JSON_FLOAT;
		static /*const*/ JSONInteger		DEFAULT_JSON_INTEGER;
		static /*const*/ JsonAbstractNode	DEFAULT_JSON_ABSTRACT;
	}
}

#endif